home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 215 < prev    next >
Encoding:
Text File  |  1996-08-06  |  3.0 KB  |  78 lines

  1. Path: news.crd.ge.com!usenet
  2. From: Christopher R Volpe <volpe@ash.crd.ge.com>
  3. Newsgroups: comp.lang.c,comp.std.c
  4. Subject: Re: Integral conversion e.t.c. (was: Re: Hungarian notation)
  5. Date: Mon, 29 Jan 1996 08:35:48 -0500
  6. Organization: GE Corporate Research & Development, Schenectady, NY
  7. Message-ID: <310CCD34.2B72@ash.crd.ge.com>
  8. References: <30C40F77.53B5@swsbbs.com> <SPENCER.96Jan22113215@zorgon.ERA.COM> <KANZE.96Jan26164833@gabi.gabi-soft.fr> <DLtABq.Fzu@mv.mv.com> <4edqh2$rvl@solutions.solon.com>
  9. NNTP-Posting-Host: bart.crd.ge.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b4 (X11; I; SunOS 5.4 sun4m)
  14.  
  15. Peter Seebach wrote:
  16. > In article <DLtABq.Fzu@mv.mv.com>, Michael Furman <ENGR@GSSI.MV.COM> wrote:
  17. > [Re a rule forbidding extensions.]
  18. > >My question was: is such rule exists?
  19. > Sort of.
  20. > There are two kinds of things called "legal" C.  One is a strictly
  21. > conforming program, which must be accepted by, and work on, *any*
  22. > conforming C compiler.  The other is merely a conforming
  23. > program, which must be accepted by, and work on, *at least one*
  24. > conforming compiler.  The latter class is meaningless; FORTRAN is
  25. > conforming C.  (gcc with g77 compiles it.  Technically, gcc is not
  26. > quite conforming, but nothing is.)
  27. > For purposes of the C newsgroups, discussion of what is/isn't legal
  28. > is generally restricted to strictly conforming C.  Any extension
  29. > used allows a compiler to reject code. 
  30.  
  31. This is not quite true. There is another class of programs which
  32. officially has no name but a bunch of regulars on comp.std.c had adopted
  33. the names "strongly conforming" and "portably conforming" to describe
  34. it. It is the class of programs that contain no syntax errors or
  35. constraint violations, and does not invoke undefined behavior. They may
  36. rely upon unspecified or implementation-defined behavior, however. These
  37. programs must work "properly" on amy implementation, but the definition
  38. of "properly" varies from implementation to implementation. The vast
  39. majority of real C software fits into this category, or can be made to
  40. fit into this category through bug fixes. (In other words, it may be
  41. impossible to make real practical software "strictly conforming", but it
  42. should always be possible to make real practical software "strongly
  43. conforming". ) It would be nice to see this terminology officially
  44. adopted in the next Standard. 
  45.  
  46. Here's an example of a non-strictly-conforming program that no compiler
  47. is allowed to reject (mod any obvious typos I may make here):
  48.  
  49.     #include <stdio.h>
  50.     int h()
  51.     {
  52.       printf("Hello"); return 0;
  53.     }
  54.     int g()
  55.       printf("Goodbye"); return 0;
  56.     }
  57.     void foo(int a, int b)
  58.     {
  59.     }
  60.     int main()
  61.     { 
  62.       foo(h(),g());
  63.     }
  64.  
  65. The output of this program can be either "HelloGoodbye" or
  66. "GoodbyeHello", but not "Segmentation violation (core dumped)".
  67.  
  68. --
  69.  
  70. Chris Volpe                Phone: (518) 387-7766 (Dial Comm 8*833
  71. GE Corporate R&D            Fax:   (518) 387-6560
  72. PO Box 8, Schenectady, NY 12301        Email: volpecr@crd.ge.com
  73.